<template>
  <div>
    
    <!-- 图文列表区域 使用的是mui中的media-list.html-->
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newlist" :key='item.id'>
        <router-link :to="'/home/newinfo/'+item.id">
          <img class="mui-media-object mui-pull-left" :src="item.img_url">
          <div class="mui-media-body">
            <h1>{{item.title}}</h1>
            <p class='mui-ellipsis'>
              <span>发表时间：{{item.add_time|dateFormat}}</span>
              <span>点击：{{item.click}}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>

  </div>
</template>


<script>
import {toast} from 'mint-ui'
export default{
  data(){
    return {//为组件模板提供数据
      newlist:[]
    }
  },
  created(){
   this.getdata()
  },
  methods:{
    getdata(){
      this.$http.get('api/getnewslist').then(result=>{//全局配置完根路径的api/getnewslist前面不能加/
       if(result.body.status==0){
          this.newlist=result.body.message
       }else{
          toast('失败')
       }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.mui-media-body {
  h1 {
    font-size: 14px;
  }

  .mui-ellipsis {
    color: #26a2ff;
    font-size: 12px;
    display: flex;//先把容器设置为伸缩盒子
    justify-content: space-between;//内容左右对齐
  }
}
</style>
